﻿using RuoVea.Service.Notice;
using Microsoft.AspNetCore.Mvc;
using RuoVea.Service;

namespace RuoVea.Api.Controllers.Notice
{
    /// <summary>
    /// 通知公告服务
    /// </summary>
    public class SysNoticeController :   ApiBaseController 
    {
        private readonly ISysNoticeService _sysNoticeService;
       /// <summary>
       /// 
       /// </summary>
       /// <param name="sysNoticeService"></param>
        public SysNoticeController(ISysNoticeService  sysNoticeService)
        {
            _sysNoticeService = sysNoticeService;
        }

        /// <summary>
        /// 分页查询通知公告
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("page")]
        public async Task<dynamic> QueryNoticePageList([FromQuery] NoticeInput input)
        {
            return await _sysNoticeService.QueryNoticePageList(input);
        }

        /// <summary>
        /// 增加通知公告
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("add")]
        public async Task AddNotice(AddNoticeInput input)
        {
              await _sysNoticeService.AddNotice(input);

        }

        /// <summary>
        /// 删除通知公告
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("delete")]
        public async Task DeleteNotice(DeleteNoticeInput input)
        {
            await _sysNoticeService.DeleteNotice(input);
        }

        /// <summary>
        /// 更新通知公告
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("edit")]
        public async Task UpdateNotice(UpdateNoticeInput input)
        {
            await _sysNoticeService.UpdateNotice(input);
        }

        /// <summary>
        /// 获取通知公告详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("detail")]
        public async Task<NoticeDetailOutput> GetNotice([FromQuery] QueryNoticeInput input)
        {
          return  await _sysNoticeService.GetNotice(input);
        }

        /// <summary>
        /// 修改通知公告状态
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("changeStatus")]
        public async Task ChangeStatus(ChangeStatusNoticeInput input)
        {
              await _sysNoticeService.ChangeStatus(input);
        }

        /// <summary>
        /// 获取接收的通知公告
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("received")]
        public async Task<dynamic> ReceivedNoticePageList([FromQuery] NoticeInput input)
        {
          return  await _sysNoticeService.ReceivedNoticePageList(input);
        }

        /// <summary>
        /// 未处理消息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("unread")]
        public async Task<dynamic> UnReadNoticeList([FromQuery] NoticeInput input) {
           return   await _sysNoticeService.ReceivedNoticePageList(input);
        }
    }
}
